    // Google gadget user preferences
    var prefs = new gadgets.Prefs();
    var html = "";
    var div = document.getElementById('content_div');


	function version() {
	  div.innerHTML = "JS version 0.2";
	};
		
	function makeDOMRequest() {    
        var params = {};  
        params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.DOM;  
        var url = "http://api.eve-online.com/server/ServerStatus.xml.aspx";  
        gadgets.io.makeRequest(url, response, params);
    };
	  
	function response(obj) { 
		//Build gadget layout
		var html = "<div style='padding: 5px;font-family:Arial, Helvetica;" 
          + "text-align:center;font-size:90%'>";   
        html +="<div style='text-align:center; font-size: 120%; color: black; " 
          + "font-weight: 700;'>"; 
        
        var domdata = obj.data;

        //Set the title
		var title = "Tranquility";
        html += title + "</div><hr>"; 
	    
		var serverOpen = "Unknown";
		var onlinePlayers = "0";
		
        var itemList = domdata.getElementsByTagName("result");
        for (var i = 0; i < itemList.length ; i++) { 

        // Fetch the data.
        var nodeList = itemList.item(i).childNodes;
        for (var j = 0; j < nodeList.length ; j++) {
          var node = nodeList.item(j);
          if (node.nodeName == "serverOpen") {
            if (node.firstChild.nodeValue == "True") {;
				serverOpen = "ok";
			}
          }
          if (node.nodeName == "onlinePlayers") 
          {
            onlinePlayers = node.firstChild.nodeValue;
          }
        } 
			//Build the body
			html += "Server status: <b>" + serverOpen;
			html += "</b><br>";
			html += "Online pilots:<b>" + onlinePlayers;
			html += "</b><br><br>";
		} 
		// Close the div
		html += "</div>";
		div.innerHTML = html;
		gadgets.window.adjustHeight();
	  };

	
	gadgets.util.registerOnLoadHandler(makeDOMRequest);
